import { getCoupon , addCoupon } from '@/apis/marketing'
import { ProductModelType } from '../interface/marketInterface'
import { Button, message, Space } from 'antd';

const orderModel: ProductModelType = {
    namespace: "marketing",
    state: {
        marketData:[],
        addData:[]
    },
    effects: {
        //query就是一个函数，函数的类型Effect
        *query({ payload }, { call, put }): any {
            const res: any = yield call(getCoupon, payload)
            console.log("getCoupon",res.data.data);
            yield put({
                type: "initData",
                payload: res.data.data
            });
        },
        *addConpon({ payload }, { call, put }): any {
            const res: any = yield call(addCoupon, payload)
            console.log("addCoupon",res.data);
            // yield put({
            //     type: "initData",
            //     payload: res.data.data
            // });

        },


    },
    reducers: {
        initData(state, action) {
            // console.log(action.payload);
            state.marketData = action.payload
        },
        addConponData(state, action) {
            // console.log(action.payload);
            state.addData = action.payload
        },
        // subscriptions: { setup: Subscription };
    }
}

export default orderModel